/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GiveTakeGlobalParametersComponent.java
 *
 * Created on 13/Dez/2011, 19:24:23
 */

package intopo.game.impl.givetake;

import intopo.game.gui.AbstractGlobalParametersComponent;

import java.awt.Color;
import javax.swing.UIManager;

/**
 * Component that allows a user to set global parameters that affect all instances of strategies in the Give-Take game.
 *
 * @see GiveTakeProbabilisticStrategy.Parameters
 * @see GiveTakeDeterministicStrategy.Parameters
 *
 * @author <a href="mailto:mariano.pedro@gmail.com">Pedro Mariano</a>
 *
 * @version 1.0 13/Dez/2011
 */
public class GiveTakeGlobalParametersComponent
	extends AbstractGlobalParametersComponent
{

	/** Creates new form GiveTakeGlobalParametersComponent */
	public GiveTakeGlobalParametersComponent ()
	{
		initComponents ();
	}
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   private void initComponents() {
      java.awt.GridBagConstraints gridBagConstraints;

      javax.swing.JTabbedPane tabbedPane = new javax.swing.JTabbedPane();
      javax.swing.JPanel deterministicPanel = new javax.swing.JPanel();
      javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
      maxGiveTimeDetFormattedTextField = new javax.swing.JFormattedTextField();
      javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
      maxTakeTimeDetFormattedTextField = new javax.swing.JFormattedTextField();
      binomialSuccessFormattedTextField = new javax.swing.JFormattedTextField();
      javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
      javax.swing.JPanel probabilisticPanel = new javax.swing.JPanel();
      javax.swing.JLabel jLabel4 = new javax.swing.JLabel();
      maxGiveTimeProFormattedTextField = new javax.swing.JFormattedTextField();
      javax.swing.JLabel jLabel5 = new javax.swing.JLabel();
      maxTakeTimeProFormattedTextField = new javax.swing.JFormattedTextField();
      javax.swing.JLabel jLabel6 = new javax.swing.JLabel();
      stddevTimeProFormattedTextField = new javax.swing.JFormattedTextField();
      stddevProbabilityProFormattedTextField = new javax.swing.JFormattedTextField();
      javax.swing.JLabel jLabel7 = new javax.swing.JLabel();

      setLayout(new java.awt.BorderLayout());

      deterministicPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
      deterministicPanel.setLayout(new java.awt.GridBagLayout());

      jLabel1.setLabelFor(maxGiveTimeDetFormattedTextField);
      jLabel1.setText("Max give time: ");
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      deterministicPanel.add(jLabel1, gridBagConstraints);

      maxGiveTimeDetFormattedTextField.setColumns(5);
      maxGiveTimeDetFormattedTextField.setValue(new Integer (GiveTakeDeterministicStrategy.Parameters.giveIteration));
      maxGiveTimeDetFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            maxGiveTimeDetFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      deterministicPanel.add(maxGiveTimeDetFormattedTextField, gridBagConstraints);

      jLabel2.setLabelFor(maxTakeTimeDetFormattedTextField);
      jLabel2.setText("Max take time: ");
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      deterministicPanel.add(jLabel2, gridBagConstraints);

      maxTakeTimeDetFormattedTextField.setColumns(5);
      maxTakeTimeDetFormattedTextField.setValue(new Integer (GiveTakeDeterministicStrategy.Parameters.takeIteration));
      maxTakeTimeDetFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            maxTakeTimeDetFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      deterministicPanel.add(maxTakeTimeDetFormattedTextField, gridBagConstraints);

      binomialSuccessFormattedTextField.setColumns(5);
      binomialSuccessFormattedTextField.setValue(new Float (GiveTakeDeterministicStrategy.Parameters.binomialSuccess));
      binomialSuccessFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            binomialSuccessFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      deterministicPanel.add(binomialSuccessFormattedTextField, gridBagConstraints);

      jLabel3.setLabelFor(binomialSuccessFormattedTextField);
      jLabel3.setText("Success probability binomial distribution mutate time: ");
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      deterministicPanel.add(jLabel3, gridBagConstraints);

      tabbedPane.addTab("deterministic", deterministicPanel);

      probabilisticPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
      probabilisticPanel.setLayout(new java.awt.GridBagLayout());

      jLabel4.setLabelFor(maxGiveTimeDetFormattedTextField);
      jLabel4.setText("Max give time: ");
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      probabilisticPanel.add(jLabel4, gridBagConstraints);

      maxGiveTimeProFormattedTextField.setColumns(5);
      maxGiveTimeProFormattedTextField.setValue(new Integer (GiveTakeProbabilisticStrategy.Parameters.maxGiveTime));
      maxGiveTimeProFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            maxGiveTimeProFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      probabilisticPanel.add(maxGiveTimeProFormattedTextField, gridBagConstraints);

      jLabel5.setLabelFor(maxTakeTimeDetFormattedTextField);
      jLabel5.setText("Max take time: ");
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      probabilisticPanel.add(jLabel5, gridBagConstraints);

      maxTakeTimeProFormattedTextField.setColumns(5);
      maxTakeTimeProFormattedTextField.setValue(new Integer (GiveTakeProbabilisticStrategy.Parameters.maxTakeTime));
      maxTakeTimeProFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            maxTakeTimeProFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      probabilisticPanel.add(maxTakeTimeProFormattedTextField, gridBagConstraints);

      jLabel6.setLabelFor(binomialSuccessFormattedTextField);
      jLabel6.setText("Success probability binomial distribution mutate time: ");
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      probabilisticPanel.add(jLabel6, gridBagConstraints);

      stddevTimeProFormattedTextField.setColumns(5);
      stddevTimeProFormattedTextField.setValue(new Float (GiveTakeProbabilisticStrategy.Parameters.timeStddev));
      stddevTimeProFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            stddevTimeProFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      probabilisticPanel.add(stddevTimeProFormattedTextField, gridBagConstraints);

      stddevProbabilityProFormattedTextField.setColumns(5);
      stddevProbabilityProFormattedTextField.setValue(new Float (GiveTakeProbabilisticStrategy.Parameters.probStddev));
      stddevProbabilityProFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            stddevProbabilityProFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      probabilisticPanel.add(stddevProbabilityProFormattedTextField, gridBagConstraints);

      jLabel7.setLabelFor(binomialSuccessFormattedTextField);
      jLabel7.setText("Success probability binomial distribution mutate probability: ");
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      probabilisticPanel.add(jLabel7, gridBagConstraints);

      tabbedPane.addTab("probabilistic", probabilisticPanel);

      add(tabbedPane, java.awt.BorderLayout.CENTER);
   }// </editor-fold>//GEN-END:initComponents

	 private void maxGiveTimeDetFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_maxGiveTimeDetFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final int value = (Integer) this.maxGiveTimeDetFormattedTextField.getValue ();
			boolean ok = value > 0;
			if (ok) {
				GiveTakeDeterministicStrategy.Parameters.giveIteration = value;
			}
			this.update (this.maxGiveTimeDetFormattedTextField, ok);
		}
}//GEN-LAST:event_maxGiveTimeDetFormattedTextFieldPropertyChange

	 private void maxTakeTimeDetFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_maxTakeTimeDetFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final int value = (Integer) this.maxTakeTimeDetFormattedTextField.getValue ();
			final boolean ok = value > 0;
			if (ok) {
				GiveTakeDeterministicStrategy.Parameters.takeIteration = value;
			}
			this.update (this.maxTakeTimeDetFormattedTextField, ok);
		}
}//GEN-LAST:event_maxTakeTimeDetFormattedTextFieldPropertyChange

	 private void binomialSuccessFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_binomialSuccessFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final float value = (Float) this.binomialSuccessFormattedTextField.getValue ();
			final boolean ok = value >= 0 && value <= 1;
			if (ok) {
				GiveTakeDeterministicStrategy.Parameters.binomialSuccess = value;
			}
			this.update (this.binomialSuccessFormattedTextField, ok);
		}
}//GEN-LAST:event_binomialSuccessFormattedTextFieldPropertyChange

	 private void maxGiveTimeProFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_maxGiveTimeProFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final int value = (Integer) this.maxGiveTimeProFormattedTextField.getValue ();
			final boolean ok = value > 0;
			if (ok) {
				GiveTakeProbabilisticStrategy.Parameters.maxGiveTime = value;
			}
			this.update (this.maxGiveTimeProFormattedTextField, ok);
		}
}//GEN-LAST:event_maxGiveTimeProFormattedTextFieldPropertyChange

	 private void maxTakeTimeProFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_maxTakeTimeProFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final int value = (Integer) this.maxTakeTimeProFormattedTextField.getValue ();
			final boolean ok = value > 0;
			if (ok) {
				GiveTakeProbabilisticStrategy.Parameters.maxTakeTime = value;
			}
			this.update (this.maxTakeTimeProFormattedTextField, ok);
		}
}//GEN-LAST:event_maxTakeTimeProFormattedTextFieldPropertyChange

	 private void stddevTimeProFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_stddevTimeProFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final float value = (Float) this.stddevTimeProFormattedTextField.getValue ();
			final boolean ok = value >= 0 && value <= 1;
			if (ok) {
				GiveTakeProbabilisticStrategy.Parameters.timeStddev = value;
			}
			this.update (this.stddevTimeProFormattedTextField, ok);
		}
}//GEN-LAST:event_stddevTimeProFormattedTextFieldPropertyChange

	 private void stddevProbabilityProFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_stddevProbabilityProFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final float value = (Float) this.stddevProbabilityProFormattedTextField.getValue ();
			final boolean ok = value >= 0 && value <= 1;
			if (ok) {
				GiveTakeProbabilisticStrategy.Parameters.probStddev = value;
			}
			this.update (this.stddevProbabilityProFormattedTextField, ok);
		}
}//GEN-LAST:event_stddevProbabilityProFormattedTextFieldPropertyChange


   // Variables declaration - do not modify//GEN-BEGIN:variables
   private javax.swing.JFormattedTextField binomialSuccessFormattedTextField;
   private javax.swing.JFormattedTextField maxGiveTimeDetFormattedTextField;
   private javax.swing.JFormattedTextField maxGiveTimeProFormattedTextField;
   private javax.swing.JFormattedTextField maxTakeTimeDetFormattedTextField;
   private javax.swing.JFormattedTextField maxTakeTimeProFormattedTextField;
   private javax.swing.JFormattedTextField stddevProbabilityProFormattedTextField;
   private javax.swing.JFormattedTextField stddevTimeProFormattedTextField;
   // End of variables declaration//GEN-END:variables

}

// Local Variables:
// mode: java
// mode: flyspell-prog
// ispell-local-dictionary: "british"
// End:
